

class Person:
    def __init__(self, name, age=0):
        self.name = name
        self.age = age
    # python方法默认都是public的，
    # 约定1个下划线_开头的方法是私有的，只是约定而已
    #  2个__下划线开头的方法不能直接访问
    def _sayHi(self): 
        print("Hi, my name is ", self.name)
    @classmethod
    def class_method(cls):
        print("Person class_method ", cls.__name__)
    
    @staticmethod
    def static_method():
        print('static method')
    
class Teacher(Person):
    def __init__(self, name, age, subject):
        super().__init__(name, age)
        self.subject = subject

    def teach(self):
        print(f'{self.name} is teaching {self.subject}')
    
    @classmethod    
    def class_methodt(cls):
       print("Teacher class_method ", cls.__name__)

    def sayHi(self):
        print("Hi, Teacher name is ", self.name)

person = Person("Alice", 30)
person._sayHi()  # 输出: Hi, my name is Alice
teacher = Teacher("Bob", 40, "Math")
teacher.sayHi()  # 输出: Hi, Teacher name is Bob

person.class_method()
Person.static_method()
teacher.class_methodt()